package src.com.doit.demo03;

import java.util.Comparator;
import java.util.TreeMap;

public class test_treeMap {
    public static void main(String[] args) {
        TreeMap<Student,String>map = new TreeMap<>();
        map.put(new Student("段哥哥",23),"上海");
        map.put(new Student("短歌行",23),"北京");
        map.put(new Student("李白",123),"石家庄");
        map.put(new Student("大河之剑天上来",213),"天津");
        System.out.println(map);

        TreeMap<Student,String>map2 = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge()-o2.getAge();
            }
        });
        map2.put(new Student("三行三列",01),"茅屋为秋风所破歌");
        map2.put(new Student("我不会啊",02),"我没见过啊");
        map2.put(new Student("你这个学习态度",03),"很不对劲儿");

        System.out.println(map2);

        System.out.println("++++++键相同,值不同+++++++++++");
        TreeMap<String,Integer>mapp = new TreeMap<>();
        mapp.put("短歌行",18);
        mapp.putIfAbsent("短歌行",19);
        System.out.println(mapp);

    }
}
